// import React from 'react'  // 组件中如果没有使用到React, 可以选择不引入
import React, {Component} from 'react'
import LifeTest from './components/LifeTest'
import LifeTest2 from './components/LifeTest2'


class App extends Component {

  state = {count: 1}

  /* 1. 父组件: 定义更新state数据的函数, 并传递给子组件 */
  updateCount = (num) => {
    this.setState({count: this.state.count + num})
  }

  render () {
    const {count} = this.state
    return <div>
      <h2>App组件: count: {count}</h2>
      <button onClick={() => this.setState({count: count + 1})}>更新count</button>

      {count<5 && <LifeTest count={count}/>}

      {count<5 && <LifeTest2 count={count}/>}
    </div>
  }
}

export default App